package test.mapaction;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;

/**
 * Created by Arat.Wu on 2018/09/10.
 */
public class MapAction {
    private static String string = "0";
    private static Integer integer = 0;
    private static Info info;

    @Data
    private static class Info {
        private Long id;
        private Long code;

        private static class Builder {
            private Long id;
            private Long code;

            public Builder id(Long id) {
                this.id = id;
                return this;
            }

            public Builder code(Long code) {
                this.code = code;
                return this;
            }

            private Info bulid() {
                Info info = new Info();
                info.setId(id);
                info.setCode(code);
                return info;
            }
        }

        private static Info.Builder builder() {
            return new Builder();
        }


    }

    ;

    public MapAction() {
        info = Info.builder().code(111L).id(111L).bulid();
    }

    private static Integer actionMethod(String o) {
        string = string + o;
        integer = Integer.valueOf(o) + 1;
        info.setCode(11111L);
        return Integer.valueOf(o) + 1;
    }

    ;

    public static void main(String[] args) {
        String flag = "1";
        Map<String, Function<String, Integer>> functionMap = new HashMap<>();
        functionMap.put("1", MapAction::actionMethod);
        functionMap.put("2", MapAction::actionMethod);

        Integer s = functionMap.get(flag).apply(flag);

        System.out.println(s);
        System.out.println(string);
        System.out.println(integer);
        System.out.println(info);

    }
}
